//
//  FeedbackViewController.m
//  EducationAdminClient
//
//  Created by KWSD_F on 16/3/31.
//  Copyright © 2016年 周佳兴. All rights reserved.
//

#import "FeedbackViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "Masonry.h"
#import "MyButton.h"
#import "testNewGongNengViewController.h"

#import "EditModel.h"


#import "KeyValuesClass.h"

@interface FeedbackViewController ()<UITextViewDelegate>
{
    NSTimer *_timer;
    UITextView *_tv;
    UIButton *_submitBtn;
    UIAlertView *_alert;
    UILabel *_titleLabel;
    UILabel *_placeholder;
    KeyValuesClass *_keyValueClass;
    NSMutableDictionary *_sendMutDic;
    NSString *_parentTableId;
    NSString *_parentPageId;
    BOOL addSucceed;
}


@property (nonatomic, strong)NSString *contentKey;
@property (nonatomic, strong)NSString *userIdKey;
@property(nonatomic,assign)NSInteger tNum;
@property(nonatomic,strong)NSString *tString;

@end

@implementation FeedbackViewController


-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    self.cusTabView.hidden = YES;
}

-(void)viewWillDisappear:(BOOL)animated{
    self.cusTabView.userInteractionEnabled = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    _keyValueClass = [[KeyValuesClass alloc]init];
    
    self.tString =[NSString stringWithFormat:@"t%li", (long)_tNum];

    _sendMutDic = [[NSMutableDictionary alloc]init];
    [self createUI];
    [self createLeftNavBar];
    if([getUIStyle() isEqualToString:STYLE0]){
        
        NSDictionary *feedBackDictionary = feedBackDic();
        
        self.tableId = [NSString stringWithFormat:@"%@",[feedBackDictionary objectForKey:@"tableId"]];
        self.pageId = [NSString stringWithFormat:@"%@",[feedBackDictionary objectForKey:@"pageId"]];
        [self dt1];
    }else{
        NSDictionary *feedBackDictionary = feedBackDic();
        
        self.tableId = [NSString stringWithFormat:@"%@",[feedBackDictionary objectForKey:@"tableId"]];
        self.pageId = [NSString stringWithFormat:@"%@",[feedBackDictionary objectForKey:@"pageId"]];
        [self dt1];
    }
    
    
    self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:56/255.0f green:64/255.0f  blue:77/255.0f alpha:1.0f];
    //566477
    
    
}

-(void)dt1{
    
    NSString *requestUrl;
    NSMutableDictionary *parmas = [[NSMutableDictionary alloc]init];
    
        [parmas setObject:userName() forKey:@"loginName"];
        [parmas setObject:passWord() forKey:@"password"];
    
        [parmas setObject:@"" forKey:@"alterTime"];
        
        
        [parmas setObject:[NSString stringWithFormat:@"%i", 20] forKey:@"limit"];
        [parmas setObject:[NSString stringWithFormat:@"%i", 0] forKey:@"start"];
        
        //    NSString *requestStr =getUrl(List_URL);
        
    
        requestUrl = [NSString stringWithFormat:@"%@%@", self.programaUrl, LISTSVIEWREQUEST_URL];
        
    if (![self.tableId isEqualToString:@""]) {
        [parmas setObject:self.tableId forKey:@"tableId"];
    }
    if (![self.pageId isEqualToString:@""]) {
        [parmas setObject:self.pageId forKey:@"pageId"];
    }
    
    
    
        
        
        
    
    
    
    
    
    [NetRequest requestUrl:requestUrl andParamas:parmas andReturnBlock:^(NSData *data, NSError *error) {
        
        
        if(data !=nil&&!error){
            
            NSDictionary *obj = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
            NSLog(@"%@", obj);
            if ([obj valueForKey:@"pageSet"]) {
                NSArray *arrButtons = [[obj valueForKey:@"pageSet"]valueForKey:@"buttonSet"];
                [self dataRequest:arrButtons];
            }
        }else{
            
            NSString *str = [NSString stringWithFormat:@"%@", error.localizedDescription];
            [self showLabelWithText:str];
        }
        
    }];
    

}
-(void)dataRequest:(NSArray *)arrButtons{
    
    NSDictionary *dicBtn;
    
    if (arrButtons.count>0) {
        dicBtn = arrButtons[0];
    }
    NSMutableDictionary *parmas = [[NSMutableDictionary alloc]init];
    [parmas setObject:userName() forKey:@"loginName"];
    [parmas setObject:passWord() forKey:@"password"];
    
    NSString *requestStr;
    //    pageId=240&tableId=70&mainId=75&mainTableId=19&mainPageId=152
    
    requestStr = [NSString stringWithFormat:@"%@%@", self.programaUrl, ADDMF_URL];
    NSString *strTnum = [NSString stringWithFormat:@"%li", (long)_tNum];
    [parmas setObject:strTnum forKey:@"tNumber"];
    
    [parmas setObject:[dicBtn valueForKey:@"startTurnPage"] forKey:@"pageId"];
    [parmas setObject:[dicBtn valueForKey:@"tableId"] forKey:@"tableId"];
    _parentPageId = [dicBtn valueForKey:@"startTurnPage"];
    _parentTableId = [dicBtn valueForKey:@"tableId"];
    
    [parmas setObject:@"" forKey:@"alterTime"];
    
    
    [NetRequest requestUrl:requestStr andParamas:parmas andReturnBlock:^(NSData *data, NSError *error) {
        
        if(data!=nil&&!error){
            
            NSDictionary *obj = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
            
            // 数据处理，当没问题的情况下
            [self dataUse:obj andDicButton:dicBtn];
            //            _itemDic = [obj valueForKey:@"dataInfo"];
            //            [self.tbView reloadData];
        }else{
            NSString *str = [NSString stringWithFormat:@"%@", error.localizedDescription];
            [self showLabelWithText:str];
            
        }
        
        [self.tbView reloadData];
        
    }];
}


#pragma mark - 数据处理
-(void)dataUse:(id)obj andDicButton:(NSMutableDictionary *)dicBtn{
    //***jsonModel 数据处理 , 如果键值对有所改变 ， 那么就将 model 内的 内容进行更改，注意 使用时的问题 ， cellForrowInThePath
    //    _conditionShow = [[NSMutableArray alloc]init];
    
    
    
    if([obj objectForKey:@"pageSet"]){
        
        
        NSArray *dataArr = [[obj objectForKey:@"pageSet"]valueForKey:@"fieldSet"];
        for (NSDictionary *dic in dataArr) {
            EditModel *model = [[EditModel alloc]init];
            model = [model initWithDictionary:dic error:nil];
            NSString *modelDefaultValueChange = [NSString stringWithFormat:@"%@", model.ifShowDefVal];
            if ([modelDefaultValueChange isEqualToString:@"1"]) {
                model.true_defaultShowValName = model.dicDefaultSelect;
            }
            NSMutableArray *dataArr1 = [[NSMutableArray alloc]init];
            
            [dataArr1 addObject:model];
            
            
            
            
            
            NSString *fieldRole =[NSString stringWithFormat:@"%@", model.fieldRole];
            NSInteger num =[fieldRole integerValue];
            // 拼接上传值
            if(num == 20 || num == 21 || num == 22){// 弹层 下拉树 内部对象
                
                [_keyValueClass whileFieldRowTypeIsspeciall:model andTnum:_tNum andTstring:_tString andSendMutDic:_sendMutDic andManyMan:nil andEditDetailDic:dicBtn andReturnBlock:^(NSMutableDictionary *send, NSMutableArray *manyman, NSDictionary *dicDEdit, EditModel *model){
                    _sendMutDic = send;
                }];
            }else if(num!=-1){
                
                if(model.true_defaultShowValName){
                    [_sendMutDic setObject:model.true_defaultShowValName forKey:model.montageName];
                    self.contentKey = model.montageName;
                }else{
                    [_sendMutDic setObject:@"" forKey:model.montageName];
                }
                
            }
        }
        
        
        NSLog(@"%@",_sendMutDic);
        
        NSArray * keyArr = [_sendMutDic allKeys];
        
        for (NSString *str in keyArr) {
            if (![str isEqualToString:self.contentKey]) {
                self.userIdKey = str;
            }
        }
        
        //SArray *arrHiddenText = [[obj objectForKey:@"pageSet"]valueForKey:@"hideFieldSet"];
        
       // for (NSDictionary *dic in arrHiddenText) {
         //   EditModel *model = [[EditModel alloc]init];
           // model = [model initWithDictionary:dic error:nil];
            //[_hiddenArr addObject:model];
        //}
        
//        [self.tbView reloadData];
    }
}

- (void)createUI{
    [self setTitleLabelText:@"意见反馈"];
    _titleLabel = [[UILabel alloc] init];
    [self.view addSubview:_titleLabel];
    _titleLabel.text = @"问题和意见";
    _titleLabel.textColor = [UIColor colorWithHex:0xb2b2b2];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).offset(20/2);
        make.left.equalTo(self.view.mas_left).offset(50/2);
    }];
    _titleLabel.font = [UIFont systemFontOfSize:26/2];
    
    
    _tv = [[UITextView alloc] initWithFrame:CGRectMake(10, 30, self.view.bounds.size.width-20, 220)];
    _tv.scrollEnabled = YES;
    _tv.textColor = [UIColor blackColor];
    _tv.font = [UIFont fontWithName:@"Arial" size:32/2];
    _tv.delegate = self;
    [self.view addSubview:_tv];
    _tv.layer.masksToBounds = YES;
    _tv.layer.cornerRadius = 10.0;
    _tv.layer.borderColor = [UIColor colorWithRed:0xd0/256.0f green:0xd0/256.0f blue:0xd0/256.0f alpha:1].CGColor;
    _tv.layer.borderWidth = 1.0f;
    _tv.layer.rasterizationScale = [UIScreen mainScreen].scale;
    _tv.layer.shouldRasterize = YES;
    _tv.clipsToBounds = YES;

    _tv.backgroundColor = [UIColor whiteColor];
    [_tv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(30/2);
        make.right.equalTo(self.view.mas_right).offset(-30/2);
        make.top.equalTo(_titleLabel.mas_bottom).offset(16/2);
        make.height.equalTo(@(220));
    }];
    
    [_tv.inputView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_tv.mas_left).offset(10/2);
        make.right.equalTo(_tv.mas_right).offset(10/2);
    }];
    
    //    _tv.autoresizingMask = UIViewAutoresizingFlexibleHeight;
//    [_tv.layer setCornerRadius:10];
    
    _placeholder = [[UILabel alloc] init];
    _placeholder.text = @"请简要描述您的问题和意见";
    _placeholder.textColor = [UIColor colorWithHex:0xb6b6b6];
    _placeholder.font = [UIFont systemFontOfSize:32/2];
    [self.view addSubview:_placeholder];
    [_placeholder mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_tv.mas_top).offset(14/2);
        make.left.equalTo(_tv.mas_left).offset(20/2);
    }];
    
    
    
    _submitBtn = [UIButton  buttonWithType:UIButtonTypeSystem];
    _submitBtn.frame = CGRectMake(10, self.view.frame.size.height-49-42-64, self.view.bounds.size.width-20, 42);
    _submitBtn.backgroundColor = [UIColor colorWithHex:0xd7000f];
    _submitBtn.layer.cornerRadius = 10.0;
    [_submitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_submitBtn setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
    _submitBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [_submitBtn setTitle:@"提交反馈" forState:UIControlStateNormal];
    [_submitBtn addTarget:self action:@selector(submitBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_submitBtn];
    
    [_submitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_tv.mas_bottom).offset(80/2);
        make.left.equalTo(_tv.mas_left);
        make.right.equalTo(_tv.mas_right);
        make.height.equalTo(@(42));
    }];
    
    
    //    UIView *testView = [self createCollectionViewHeaderView];
    //    testView.frame = CGRectMake(0, 280, self.view.frame.size.width, 200);
    //    [self.view addSubview:testView];
    
    
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
    CGRect frame = _submitBtn.frame;
    frame.origin.y -= 60;
    btn.frame = frame;
    [btn setBackgroundColor:[UIColor purpleColor]];
    [btn setTitle:@"test" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(testBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
#pragma - mark 屏蔽功能
    btn.hidden = YES;
    
    
    
    
}

-(void)textViewDidChangeSelection:(UITextView *)textView
{
    NSLog(@"%@",textView.text);
    if ([textView.text isEqualToString:@""]) {
        _placeholder.hidden = NO;
    }else{
        _placeholder.hidden = YES;
    }
}


#pragma -mark testNewGN
- (void)testBtnClick
{
    //    NSLog(@"lkasjdfkjasdjf");
    testNewGongNengViewController *tvc = [[testNewGongNengViewController alloc] init];
    [self.navigationController pushViewController:tvc animated:YES];
}



//-(UIView *)createCollectionViewHeaderView{
//    UIView *baseView = [[UIView alloc]init];
//    //    CGRect rect = baseView.frame;
//    baseView.backgroundColor = [UIColor colorWithHex:0x00a8fd];
//    //    baseView.backgroundColor = [UIColor clearColor];
//
//    UIView *viewForColor = [[UIView alloc]init];
//    //    viewForColor.backgroundColor = [UIColor colorWithHex:0xffffff];
//    [baseView addSubview: viewForColor];
//
//    UIImageView *titleLefIV = [[UIImageView alloc]init];
//    [baseView addSubview:titleLefIV];
//
//    UILabel *titleLabel = [[UILabel alloc]init];
//    [baseView addSubview:titleLabel];
//
//    MyButton *myBtn = [[MyButton alloc]init];
//    myBtn.Btntag = 0;
//    [baseView addSubview:myBtn];
//
//    MyButton *myBtn1 = [[MyButton alloc]init];
//    myBtn1.Btntag = 1;
//    [baseView addSubview:myBtn1];
//
//    MyButton *myBtn2 = [[MyButton alloc]init];
//    myBtn2.Btntag = 2;
//    [baseView addSubview:myBtn2];
//
//    MyButton *myBtn3 = [[MyButton alloc]init];
//    myBtn3.Btntag = 3;
//    [baseView addSubview:myBtn3];
//
//    UILabel *titleTipLabel = [[UILabel alloc]init];
//
//    [baseView addSubview:titleTipLabel];
//
//    [titleLefIV mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(baseView.mas_left).offset(5);
//        make.width.equalTo(@(10));
//        make.height.equalTo(@(30));
//        make.top.equalTo(baseView.mas_top).offset(5);
//    }];
//
//    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(titleLefIV.mas_right).offset(3);
//        make.width.equalTo(@(70));
//        make.height.equalTo(titleLefIV.mas_height);
//        make.centerY.equalTo(titleLefIV.mas_centerY);
//    }];
//
//    [myBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(baseView.mas_left).offset(20);
//        make.width.equalTo(myBtn1.mas_width);
//        make.height.equalTo(@(80));
//        make.top.equalTo(baseView.mas_top).offset(50);
//        make.bottom.equalTo(titleTipLabel.mas_top);
//
//    }];
//
//
//    [myBtn1 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(myBtn.mas_right);
//        make.width.equalTo(myBtn.mas_width);
//        make.height.equalTo(myBtn.mas_height);
//        make.bottom.equalTo(myBtn.mas_bottom);
//    }];
//    [myBtn2 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(myBtn1.mas_right);
//        make.width.equalTo(myBtn1.mas_width);
//        make.height.equalTo(myBtn1.mas_height);
//        make.bottom.equalTo(myBtn1.mas_bottom);
//        //            make.right.equalTo(myBtn3.mas_right).offset(-20);
//    }];
//
//    [myBtn3 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(myBtn2.mas_right);
//        make.width.equalTo(myBtn2.mas_width);
//        make.height.equalTo(myBtn2.mas_height);
//        make.bottom.equalTo(myBtn2.mas_bottom);
//        make.right.equalTo(baseView.mas_right).offset(-20);
//    }];
//
//    [titleTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(baseView.mas_left);
//        make.right.equalTo(baseView.mas_right);
//        make.height.equalTo(@(60/2));
//        make.bottom.equalTo(baseView.mas_bottom);
//    }];
//
//    [viewForColor mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(baseView.mas_left);
//        make.right.equalTo(baseView.mas_right);
//        make.top.equalTo(baseView.mas_top);
//        make.bottom.equalTo(titleTipLabel.mas_top);
//    }];
//
//    titleLefIV.backgroundColor = [UIColor redColor];
//    titleLabel.text = @"快捷工具";
//
//    titleLabel.textColor = [UIColor blackColor];
//    [myBtn setTitle:@"扫码考勤" forState:UIControlStateNormal];
//    [myBtn1 setTitle:@"个人任务" forState:UIControlStateNormal];
//    [myBtn2 setTitle:@"消息提醒" forState:UIControlStateNormal];
//    [myBtn3 setTitle:@"系统设置" forState:UIControlStateNormal];
//
//    [myBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
//    [myBtn1 addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
//    [myBtn2 addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
//    [myBtn3 addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
//    [myBtn setImage:[UIImage imageNamed:@"形状-4"] forState:UIControlStateNormal];
//    [myBtn1 setImage:[UIImage imageNamed:@"形状-16"] forState:UIControlStateNormal];
//    [myBtn2 setImage:[UIImage imageNamed:@"形状-17"] forState:UIControlStateNormal];
//    [myBtn3 setImage:[UIImage imageNamed:@"形状-17"] forState:UIControlStateNormal];
//
//    [myBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//    [myBtn1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//    [myBtn2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//    [myBtn3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//
//    titleTipLabel.text = @"功能菜单";
//    titleTipLabel.textAlignment = NSTextAlignmentCenter;
//
//    return baseView;
//}
//
//-(void)btnClick:(MyButton *)myBtn{
//    NSLog(@"%ld", myBtn.Btntag);
//
//}
- (void)changeTimeAtTimedisplay
{
    [[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:NO];
    
    if (addSucceed) {
//        [self showLabelWithText:@"成功"];
    }
    
    [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(backToHomePage) userInfo:nil repeats:NO];
}

- (void)backToHomePage{
    if (addSucceed) {
        [self.navigationController popToRootViewControllerAnimated:YES];
    }
    
}


#pragma -mark 设置收起键盘事件
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [_tv resignFirstResponder];
}

#pragma -mark 设置导航栏的完成按钮
-(void)textViewDidBeginEditing:(UITextView *)textView {
    
    UIButton *doneBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    doneBtn.frame = CGRectMake(0, 0, 50, 23);
    doneBtn.titleLabel.textAlignment = NSTextAlignmentRight;
    [doneBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    doneBtn.backgroundColor = [UIColor greenColor];
    [doneBtn setTitle:@"完成" forState:UIControlStateNormal];
    [doneBtn addTarget:self action:@selector(leaveEditMode) forControlEvents:UIControlEventTouchUpInside];
    
    
    
//    UIBarButtonItem *done =[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(leaveEditMode)];
    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithCustomView:doneBtn];
    self.navigationItem.rightBarButtonItem = item;
    
}

#pragma -mark 键盘收起时隐藏导航栏完成按钮
- (void)textViewDidEndEditing:(UITextView *)textView {
    
    self.navigationItem.rightBarButtonItem  = nil;
    
}

#pragma -mark 实现完成按钮功能
-(void)leaveEditMode{
    [_tv resignFirstResponder];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma -mark submitBtn
- (void)submitBtnClick:(UIButton *)sender{
#pragma mark - 缺少一个点击按钮收起键盘的代码
//#ifdef Student
    
    [_tv resignFirstResponder];
//    return;
    NSString *tvtext = _tv.text;
    NSLog(@"%@",tvtext);
    if ([tvtext isEqualToString:@""]) {
        
        _alert =[[UIAlertView alloc]initWithTitle:@"提示" message:@"反馈内容不能为空" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [_alert show];
//        [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(performDismiss:) userInfo:nil repeats:NO];userid
        return;
    
    }
//    NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
    

    
    [NSTimer scheduledTimerWithTimeInterval:0.7 target:self selector:@selector(netRequest) userInfo:nil repeats:NO];
    
}

-(void)netRequest{
    NSString *tvtext = _tv.text;
    NSMutableDictionary *paramas = [[NSMutableDictionary alloc] init];
    
    NSString *strutf = [NSString stringWithUTF8String:"哈哈a"];
    NSLog(@"%@",strutf);//au_282_2875_3602
    //au_282_2875_3600
    if([getUIStyle() isEqualToString:STYLE0]){
        NSString *uId = userId();
        if (_parentTableId) {
            [paramas setObject:_parentTableId forKey:@"tableId"];
        }
        if (_parentPageId) {
            [paramas setObject:_parentPageId forKey:@"pageId"];
        }
        if (_contentKey) {
            [paramas setObject:tvtext forKey:_contentKey];
        }
        
        if (uId&&_userIdKey) {
            [paramas setObject:uId forKey:_userIdKey];
        }
    }else{
        NSString *uId = userId();
        if (_parentTableId) {
            [paramas setObject:_parentTableId forKey:@"tableId"];
        }
        if (_parentPageId) {
            [paramas setObject:_parentPageId forKey:@"pageId"];
        }
        if (_contentKey) {
            [paramas setObject:tvtext forKey:_contentKey];
        }
        
        if (uId&&_userIdKey) {
            [paramas setObject:uId forKey:_userIdKey];
        }
    }
    
    
    
    [paramas setObject: getSessionId() forKey:@"sessionId"];
    
    
    //    [paramas setObject:@"15701179661" forKey:@"loginName"];
    //    [paramas setObject:@"000000" forKey:@"password"];
    //2575&t0_au_280_2575=&t0_au_280_2575_3573=qwe&tableId=280
    //    NSString *url = [NSString stringWithFormat:@"%@%@?&pageId=2575&t0_au_280_2575=&t0_au_280_2575_3573=%@&tableId=280",BASE_URL,ADD_Commit_URL,tvtext];
    //    NSString *url2 = [NSString stringWithFormat:@"http://192.168.6.150:8081/edus_auto/add_interfaceAdd.do?&&pageId=2575&&t0_au_280_2575=&&t0_au_280_2575_3573=asdf&&tableId=280"];
    //    if ([url isEqualToString:url2]) {
    //        NSLog(@"laksdjflkasdf");
    //    }
    
    NSString *url3 = [NSString stringWithFormat:@"%@%@?",self.programaUrl,ADD_Commit_URL];
    [NetRequest requestUrl:url3 andParamas:paramas andReturnBlock:^(NSData *data, NSError *error) {
        if (data&&!error) {
            NSString *dataStr=  [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
            if (!([paramas objectForKey:@"tableId"]&&[paramas objectForKey:@"pageId"])) {
                [self showLabelWithText:@"暂时未开通反馈"];
            }else{
                if(![dataStr isEqualToString:@"0"]){
                    NSLog(@"%@",data);
                    id obj = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
                    NSLog(@"%@",obj);
                    
                    if ([obj valueForKey: @"promptMessage"]) {
                        [[NSNotificationCenter defaultCenter]postNotificationName:@"relogin" object:@"relogin"];
                        
                    }
                    
                    [[NSNotificationCenter defaultCenter]postNotificationName:@"shouldReload" object:@"ok"];
                    
                    _alert =[[UIAlertView alloc]initWithTitle:nil message:@"添加成功" delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
                    [_alert show];
                    [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(performDismiss:) userInfo:nil repeats:NO];
                    
                    //                self.subBtn.enabled = YES;
                    addSucceed = YES;
                    
                    //*** hidden the netWork state activity
                    [[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:NO];
                    
                    
                    
                }else{
                    _alert =[[UIAlertView alloc]initWithTitle:nil message:@"添加失败" delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
                    [_alert show];
                    [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(performDismiss:) userInfo:nil repeats:NO];
                    
                    //                self.subBtn.enabled = YES;
                    addSucceed = NO;
                    
                    //*** hidden the netWork state activity
                    [[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:NO];
                    
                }
            }
        }else{
            [self showLabelWithText:@"网络错误"];
            
            //*** hidden the netWork state activity
            [[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:NO];
            
        }
        
    }];
    //    NSURL *urlre = [[NSURL alloc] initWithString:url2];
    //    NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:urlre];
    //    //    3.发送请求
    //    //发送异步请求，在主线程执行
    //    NSOperationQueue *queue=[NSOperationQueue mainQueue];
    
    //    [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
    //        if(data!=nil&&!connectionError){
    //            NSString *dataStr=  [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
    //
    //            if(![dataStr isEqualToString:@"0"]){
    //
    //                //*** post the notifacation center should reload list view controller
    //                [[NSNotificationCenter defaultCenter]postNotificationName:@"shouldReload" object:@"ok"];
    //
    //                _alert =[[UIAlertView alloc]initWithTitle:nil message:@"添加成功" delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
    //                [_alert show];
    //                [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(performDismiss:) userInfo:nil repeats:NO];
    //
    ////                self.subBtn.enabled = YES;
    //                addSucceed = YES;
    //
    //                //*** hidden the netWork state activity
    //                [[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:NO];
    //
    //            }
    //
    //            else{
    //                _alert =[[UIAlertView alloc]initWithTitle:nil message:@"添加失败" delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
    //                [_alert show];
    //                [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(performDismiss:) userInfo:nil repeats:NO];
    //
    ////                self.subBtn.enabled = YES;
    //                addSucceed = NO;
    //
    //                //*** hidden the netWork state activity
    //                [[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:NO];
    //
    //            }
    //        }else{
    //            [self showLabelWithText:@"网络错误"];
    //
    //            //*** hidden the netWork state activity
    //            [[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:NO];
    //
    //        }
    //    }];
    
    
    //#else
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
    //    [_timer fire];
    [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(changeTimeAtTimedisplay) userInfo:nil repeats:NO];
    //#endif
}

-(void)performDismiss:(NSTimer *)timer
{
    [_alert dismissWithClickedButtonIndex:0 animated:NO];
    
    if(addSucceed)[self.navigationController popViewControllerAnimated:YES];
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
